<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<style>
.row input{
	margin-top: 5px;
}
.row select{
	margin-top: 5px;
}
</style>
<div class="form-horizontal" role="form" >
	<input id="id" value="${sysDict.id}"  type="hidden"/>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">选择所属节点:</label>
        <div class="col-md-9">
        	<select id="parentId" data-placeholder="选择所属节点" class="form-control chosen-select" tabindex="4">
				<option value="">选择所属节点</option>
			</select>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">名称:</label>
        <div class="col-md-9">
        	 <input id="lable" value="${sysDict.lable}"  type="text" placeholder="名称" class="form-control" name="lable"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">值:</label>
        <div class="col-md-9">
        	 <input id="value" value="${sysDict.value}" type="text" placeholder="值" class="form-control" name="value"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">值类型:</label>
        <div class="col-md-9 col-sm-3">
            <select id="valueType" data-placeholder="值类型" class="form-control chosen-select" tabindex="4">
        		<option value="1" <c:if test="${sysDict.valueType==1}">selected="selected"</c:if>>单选</option>
        		<option value="2" <c:if test="${sysDict.valueType==2}">selected="selected"</c:if>>多选</option>
        		<option value="3" <c:if test="${sysDict.valueType==3}">selected="selected"</c:if>>输入</option>
            </select>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">是否默认:</label>
        <div class="col-md-9 col-sm-3">
        	 <div class="checkbox">
			    <label>
			      <input type="checkbox" id="hasDefault" class="checkbox" <c:if test="${sysDict.hasDefault==1}">checked="checked"</c:if>>默认
			    </label>
			 </div>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">组类型:</label>
        <div class="col-md-9">
        	 <input id="groupType" value="${sysDict.groupType}" type="text" placeholder="组类型" class="form-control" name=groupType/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">类型:</label>
        <div class="col-md-9">
        	 <input id="type" value="${sysDict.type}" type="text" placeholder="类型" class="form-control" name=type/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">描述:</label>
        <div class="col-md-9">
        	 <input id="desc" value="${sysDict.desc}"  type="text" placeholder="描述" class="form-control" name="desc"/>
        </div>
    </div>
</div>

<script>
$.ajax({  
	url:'${ctx}/dict/list',  		 					
	type: 'POST',
	dataType:'json',  
	data:{
		status:"1",	
		parentId:"-1"					
	}, 
	success:function(response){
		if(response.code==0){
			var html=[];
			var data=response.data||[];
			for(var i=0;i<data.length;i++){
				if(data[i].id != '${sysDict.id}'){
					if(data[i].id != '${sysDict.parentId}'){
						html.push('<option value="'+data[i].id+'">'+data[i].type+' | '+data[i].lable+'</option>');
					}else{
						html.push('<option value="'+data[i].id+'" selected="selected">'+data[i].type+' | '+data[i].lable+'</option>');
					}
				}
			}
			$("#parentId").append(html.join(""));
			$("#parentId").trigger("chosen:updated");
		}
	 }  
 });
 
$("#valueType").chosen({ width: '100%' });
$("#parentId").chosen({ width: '100%' });
 
</script>
